<%@page import="org.omg.CORBA.Context"%>
<%@page import="com.nashuju.web.common.PropertiesManager"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="rms" uri="/rms" %>
<%@page import="org.durcframework.core.UserContext"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<c:set var="ctx" value='<%=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/" %>'/>

<!--Basic Styles-->
<link rel="stylesheet" type="text/css" href="${ctx}assets/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="${ctx}assets/bootstrap/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="${ctx}assets/bootstrap/css/weather-icons.min.css" />

<link href="${ctx}assets/bootstrap/css/beyond.min.css" rel="stylesheet" type="text/css" />
<link href="${ctx}assets/bootstrap/css/demo.min.css" rel="stylesheet" />
<link href="${ctx}assets/bootstrap/css/typicons.min.css" rel="stylesheet" />
<link href="${ctx}assets/bootstrap/css/animate.min.css" rel="stylesheet" />
<link type="text/css" rel="stylesheet" href="http://cdn.staticfile.org/twitter-bootstrap/3.1.1/css/bootstrap.min.css"/>


<script type="text/javascript">var ctx = '${ctx}';</script>
<script type="text/javascript">var userId = '<% out.print(UserContext.getInstance().getUser().getId());%>';</script>
<script type="text/javascript" src="${ctx}assets/jquery.js/jquery.fw.ext.js"></script>
<script src="assets/bootstrap/js/jquery-2.0.3.min.js"></script> 

<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/bootstrap/js/skins.min.js"></script>
<script src="assets/bootstrap/js/select2/select2.js"></script>
<!--Bootstrap Tags Input-->
<script src="assets/bootstrap/js/tagsinput/bootstrap-tagsinput.js"></script>
<!--Bootstrap Date Picker-->
<script src="assets/bootstrap/js/datetime/bootstrap-datepicker.js"></script>
<!--Bootstrap Time Picker-->
<script src="assets/bootstrap/js/datetime/bootstrap-timepicker.js"></script>
<!--Bootstrap Date Range Picker-->
<script src="assets/bootstrap/js/datetime/moment.js"></script>
<script src="assets/bootstrap/js/datetime/daterangepicker.js"></script>
<!--Jquery Autosize-->
<script src="assets/bootstrap/js/textarea/jquery.autosize.js"></script>
<!--Fuelux Spinner-->
<script src="assets/bootstrap/js/fuelux/spinner/fuelux.spinner.min.js"></script>
<!--jQUery MiniColors-->
<script src="assets/bootstrap/js/colorpicker/jquery.minicolors.js"></script>
<!--jQUery Knob-->
<script src="assets/bootstrap/js/knob/jquery.knob.js"></script>
<!-- paginator -->
<script src="assets/bootstrap/js/datatable/jqPaginator.js"></script>
<!--noUiSlider-->
<script src="assets/bootstrap/js/slider/jquery.nouislider.js"></script>
<script type="text/javascript" src="${ctx}assets/js/message.js"></script>

<script src="assets/bootstrap/js/bootbox/bootbox.js"></script>

<!--jQRangeSlider-->
<script src="assets/bootstrap/js/jquery-ui-1.10.4.custom.js"></script>
<script src="assets/bootstrap/js/slider/jQRangeSlider/jQAllRangeSliders-withRuler-min.js"></script>
<script src="assets/bootstrap/js/laypage.js"></script>
<script src="assets/js/zzsc.js"></script>
<script src="assets/js/myDataGride.js"></script>
<script type="text/javascript" src="${ctx}assets/jquery-easyui-1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="${ctx}assets/jquery-easyui-1.4.2/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${ctx}assets/jquery-easyui-1.4.2/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${ctx}assets/easyui.js/easyui.ext.js"></script>
<script type="text/javascript" src="${ctx}assets/easyui.js/jqPaginator.js"></script>
<link rel="stylesheet" type="text/css" href="${ctx}assets/jquery-easyui-1.4.2/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="${ctx}assets/jquery-easyui-1.4.2/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="${ctx}assets/css/easyui.icon.css" />
<style>

 .profile-container .profile-header .profile-info {
    border-right: 0!important;
    padding: 35px 10px 35px 50px;
    
}
.profile-container .profile-header {
	height: 290px;
    margin: 0px -4% 0;
}
.header-information{
    padding-left: 0px;
    padding-right: 0px;

}
.combo{
    width: 128px!important;
    height: 22px!important;
    display:inline-block;
}
.textbox {
    width: 150px;
    padding: 0;
}  

</style>


<script>
function addAction(id)
{


    $.getJSON(ctx+'listSTaskSchedule.do',{idSch:id},function(parentsJson) {
    	
    	if(parentsJson.rows[0]!=null)
    	{	
    		//console.log(parentsJson.rows[0])
	    	$("#taskNum").val(parentsJson.rows[0].taskNum);
	    	$("#id").val(parentsJson.rows[0].id==null?"":parentsJson.rows[0].id);
	    	$("#sendTime").textbox("setValue",parentsJson.rows[0].sendTime==null?"":parentsJson.rows[0].sendTime);
	        $("#executorId").combobox("setValue",parentsJson.rows[0].executorId==null?"":parentsJson.rows[0].executorId);
	        $("#taskName").combobox("setValue",parentsJson.rows[0].taskName==null?"":parentsJson.rows[0].taskName);
	        $("#customerId").combobox("setValue",parentsJson.rows[0].sCustomers[0].id==null?"":parentsJson.rows[0].sCustomers[0].id);
	        $("#province").combobox("setValue",parentsJson.rows[0].province==null?"":parentsJson.rows[0].province);
	        $("#country").combobox("setValue",parentsJson.rows[0].country==null?"":parentsJson.rows[0].country);
	        $("#faultCategory").textbox("setValue",parentsJson.rows[0].faultCategory==null?"":parentsJson.rows[0].faultCategory);
	        $("#planArriveTime").textbox("setValue",parentsJson.rows[0].planArriveTime==null?"":parentsJson.rows[0].planArriveTime);
	        $("#planFinishTime").textbox("setValue",parentsJson.rows[0].planFinishTime==null?"":parentsJson.rows[0].planFinishTime);
	        $("#taskType").textbox("setValue",parentsJson.rows[0].taskType==null?"":parentsJson.rows[0].taskType);
	        $("#level").textbox("setValue",parentsJson.rows[0].sCustomers[0].level==null?"":parentsJson.rows[0].sCustomers[0].level);
	        $("#transportation").textbox("setValue",parentsJson.rows[0].transportation==null?"":parentsJson.rows[0].transportation);
	        $("#contactName").textbox("setValue",parentsJson.rows[0].contactName==null?"":parentsJson.rows[0].contactName);
	        $("#position").textbox("setValue",parentsJson.rows[0].position==null?"":parentsJson.rows[0].position);
	        $("#fixedPhone").textbox("setValue",parentsJson.rows[0].fixedPhone==null?"":parentsJson.rows[0].fixedPhone);
	        $("#contactPhone").textbox("setValue",parentsJson.rows[0].contactPhone==null?"":parentsJson.rows[0].contactPhone);
	        $("#charge").textbox("setValue",parentsJson.rows[0].charge==null?"":parentsJson.rows[0].charge);
	        $("#workHours").textbox("setValue",parentsJson.rows[0].workHours==null?"":parentsJson.rows[0].workHours);
	        $("#fixedPhone").textbox("setValue",parentsJson.rows[0].fixedPhone==null?"":parentsJson.rows[0].fixedPhone);
	        $("#issueReason").val(parentsJson.rows[0].issueReason==null?"":parentsJson.rows[0].issueReason);
	        $("#sendDemand").val(parentsJson.rows[0].sendDemand==null?"":parentsJson.rows[0].sendDemand);
	        $("#liveSituation").val(parentsJson.rows[0].liveSituation==null?"":parentsJson.rows[0].liveSituation);
	        $("#processResult").val(parentsJson.rows[0].processResult==null?"":parentsJson.rows[0].processResult);
	        $("#visiteRecord").val(parentsJson.rows[0].visiteRecord==null?"":parentsJson.rows[0].visiteRecord);
	        $("#revisitRecord").val(parentsJson.rows[0].revisitRecord==null?"":parentsJson.rows[0].revisitRecord);
	        $("#taskChecked").val(parentsJson.rows[0].taskChecked==null?"":parentsJson.rows[0].taskChecked);
	        setRowBeforeEdit(parentsJson.rows[0]);
	        if(parentsJson.rows[0].liveSituationUrl!=null){
	    		addImage(parentsJson.rows[0].liveSituationUrl,".liveSituationImgs");
	    	}
	    	else
	    	{
	    		$(".liveSituationImgs").empty();
	    	}
	    	 if(parentsJson.rows[0].processResultUrl!=null){
	    		addImage(parentsJson.rows[0].processResultUrl,".processResultImgs");
	    	}
	    	else
	    	{
	    		$(".processResultImgs").empty(); 
	    	}
	    	if(parentsJson.rows[0].visiteRecordUrl!=null){
	    		addImage(parentsJson.rows[0].visiteRecordUrl,".visiteRecordImgs");
	    	}
	    	else
	    	{
	    		$(".visiteRecordImgs").empty(); 
	    	}
	    	
	    	if(parentsJson.rows[0].status=="已审核"||parentsJson.rows[0].status=="已完成"||parentsJson.rows[0].status=="已回访"||parentsJson.rows[0].status=="已归档"){
	    		$(".arcivePart").css("display","block");
	    	}
	    	else{
	    		$(".arcivePart").css("display","none");
	    	}
	    	
	    	$("#ReceiptList").empty();
	    	$("#CarRecordList").empty();
	    	$("#ReceiptPage").empty();
	    	$("#CarRecordPage").empty();
	    	
	    	//报销
	    	ReimburseCheck(1, 5, true,"listSReceipt.do?taskIdSch="+parentsJson.rows[0].id ,"#ReceiptList","#ReceiptPage",["费用名称","金额","姓名"]) ;
	    	//行车记录
	    	carRecord(1, 5, true,"listSReimburse.do?taskIdSch="+parentsJson.rows[0].id,"#CarRecordList","#CarRecordPage",["费用名称","金额","姓名"]) ;
    	
	    	
	    	
	   	}
	    else
	    { 
	    	$.getJSON(ctx+'listSTaskSchedule.do',{idSch:id},function(parentsJson) {
	    		//console.log(parentsJson.rows[0]);
	    		$("#taskNum").val(parentsJson.rows[0].taskNum);
		    	$("#id").val(parentsJson.rows[0].id==null?"":parentsJson.rows[0].id);
		    	$("#sendTime").textbox("setValue",parentsJson.rows[0].sendTime==null?"":parentsJson.rows[0].sendTime);
		        $("#executorId").combobox("setValue",parentsJson.rows[0].executorId==null?"":parentsJson.rows[0].executorId);
		        $("#taskName").textbox("setValue",parentsJson.rows[0].taskName==null?"":parentsJson.rows[0].taskName);
		        $("#customerId").combobox("setValue",parentsJson.rows[0].sCustomers[0].id==null?"":parentsJson.rows[0].sCustomers[0].id);
		        $("#province").combobox("setValue",parentsJson.rows[0].province==null?"":parentsJson.rows[0].province);
		        $("#country").combobox("setValue",parentsJson.rows[0].country==null?"":parentsJson.rows[0].country);
		        $("#faultCategory").textbox("setValue",parentsJson.rows[0].faultCategory==null?"":parentsJson.rows[0].faultCategory);
		        $("#planArriveTime").textbox("setValue",parentsJson.rows[0].planArriveTime==null?"":parentsJson.rows[0].planArriveTime);
		        $("#planFinishTime").textbox("setValue",parentsJson.rows[0].planFinishTime==null?"":parentsJson.rows[0].planFinishTime);
		        $("#taskType").textbox("setValue",parentsJson.rows[0].taskType==null?"":parentsJson.rows[0].taskType);
		        $("#level").textbox("setValue",parentsJson.rows[0].sCustomers[0].level==null?"":parentsJson.rows[0].sCustomers[0].level);
		        $("#transportation").textbox("setValue",parentsJson.rows[0].transportation==null?"":parentsJson.rows[0].transportation);
		        $("#contactName").textbox("setValue",parentsJson.rows[0].contactName==null?"":parentsJson.rows[0].contactName);
		        $("#position").textbox("setValue",parentsJson.rows[0].position==null?"":parentsJson.rows[0].position);
		        $("#fixedPhone").textbox("setValue",parentsJson.rows[0].fixedPhone==null?"":parentsJson.rows[0].fixedPhone);
		        $("#contactPhone").textbox("setValue",parentsJson.rows[0].contactPhone==null?"":parentsJson.rows[0].contactPhone);
		        $("#charge").textbox("setValue",parentsJson.rows[0].charge==null?"":parentsJson.rows[0].charge);
		        $("#workHours").textbox("setValue",parentsJson.rows[0].workHours==null?"":parentsJson.rows[0].workHours);
		        $("#fixedPhone").textbox("setValue",parentsJson.rows[0].fixedPhone==null?"":parentsJson.rows[0].fixedPhone);
		        $("#issueReason").val(parentsJson.rows[0].issueReason==null?"":parentsJson.rows[0].issueReason);
		        $("#sendDemand").val(parentsJson.rows[0].sendDemand==null?"":parentsJson.rows[0].sendDemand);
		        $("#liveSituation").val(parentsJson.rows[0].liveSituation==null?"":parentsJson.rows[0].liveSituation);
		        $("#processResult").val(parentsJson.rows[0].processResult==null?"":parentsJson.rows[0].processResult);
		        $("#visiteRecord").val(parentsJson.rows[0].visiteRecord==null?"":parentsJson.rows[0].visiteRecord);
		        $("#revisitRecord").val(parentsJson.rows[0].revisitRecord==null?"":parentsJson.rows[0].revisitRecord);
		        $("#taskChecked").val(parentsJson.rows[0].taskChecked==null?"":parentsJson.rows[0].taskChecked);
		        $("#realWorkTime").textbox("setValue",parentsJson.rows[0].realWorkTime==null?"":parentsJson.rows[0].realWorkTime);
		        setRowBeforeEdit(parentsJson.rows[0]);
		        //slideShow ();
		    	if(parentsJson.rows[0].liveSituationUrl!=null){
		    		addImage(parentsJson.rows[0].liveSituationUrl,".liveSituationImgs");
		    	
		    	}
		    	else
		    	{
		    		$(".liveSituationImgs").empty();
		    	}
		    	 if(parentsJson.rows[0].processResultUrl!=null){
		    		addImage(parentsJson.rows[0].processResultUrl,".processResultImgs");
		    	}
		    	else
		    	{
		    		$(".processResultImgs").empty(); 
		    	}
		    	if(parentsJson.rows[0].visiteRecordUrl!=null){
		    		addImage(parentsJson.rows[0].visiteRecordUrl,".visiteRecordImgs");
		    	}
		    	else
		    	{
		    		$(".visiteRecordImgs").empty(); 
		    	}
		    	
		    	$("#ReceiptList").empty();
		    	$("#CarRecordList").empty();
		    	$("#ReceiptPage").empty();
		    	$("#CarRecordPage").empty();
		    	
		    	//报销
		    	ReimburseCheck(1, 5, true,"listSReceipt.do?taskIdSch="+parentsJson.rows[0].id ,"#ReceiptList","#ReceiptPage",["费用名称","金额","姓名"]) ;
		    	//行车记录
		    	carRecord(1, 5, true,"listSReimburse.do?taskIdSch="+parentsJson.rows[0].id,"#CarRecordList","#CarRecordPage",["费用名称","金额","姓名"]) ;
	    	});
	    }
	});
    
    
}




//**********************DOM操作*********************************

  function addImage(JsonDate , id)
   {
	  
	  console.log(JsonDate);
	  $(id).empty();
	  var str ='';
	  for(var i = 0 ; i<JsonDate.length;i++)
	  {     
		  str+='<div class="col-md-6"><img src="'+JsonDate[i] +'"width=100% height=100% " /></div>';
	  }
	  $(id).append(str);
   }
//**********************DOM操作*********************************

//************combobox******************************
  $.getJSON(ctx+'listCSysClass.do',{parentIdSch:80 ,classtypeidSch:3 },function(parentsJson) {
        $("#level").combobox({
			data:parentsJson.rows,
			valueField:'text',
	         textField:'text',
	        selected:parentsJson.rows[0],
	        filter: function(q, row){
        		var opts = $(this).combobox('options');
        		return row[opts.textField].indexOf(q) == 0;
        	}
	})
	});
    //故障类别
    $.getJSON(ctx+'listCSysClass.do',{parentIdSch:76 ,classtypeidSch:3 },function(parentsJson) {
        $("#faultCategory").combobox({
			data:parentsJson.rows,
			valueField:'text',
	         textField:'text',
	        selected:parentsJson.rows[0],
	        filter: function(q, row){
        		var opts = $(this).combobox('options');
        		return row[opts.textField].indexOf(q) == 0;
        	}
	})
	});
    
    
	//二进制字段编辑前拆分的拆分
    function setRowBeforeEdit(row) {

        row.isshow = 0;
        row.issystem = 0;
        row.isindex = 0;
        row.islist = 0;
		console.log(row)
        if (1 == (row.classProperty & 1)) //发布
        	$(".isshow").attr("checked", true);
        else
        	$(".isshow").attr("checked", false);
		
        if (2 == (row.classProperty & 2)) //置顶
        	$(".issystem").attr("checked", true);
        else
        	$(".issystem").attr("checked", false);
        
        if (4 == (row.classProperty & 4)) //推荐
        	$(".isindex").attr("checked", true);
        else
        	$(".isindex").attr("checked", false);
        
        if (8 == (row.classProperty & 8)) //滚动
        	$(".islist").attr("checked", true);
        else
        	$(".islist").attr("checked", false);
    }
    
	//编辑后组合"",isindex,isindex
    function setRowAfterEdit(frmdata) {
        frmdata.classProperty = 0;
        if ($(".isshow").is(':checked')) //发布
            frmdata.classProperty += 1;
        if ($(".issystem").is(':checked')) //置顶
            frmdata.classProperty += 2;
        if ($(".isindex").is(':checked')) //推荐
            frmdata.classProperty += 4;
        if ($(".islist").is(':checked')) //滚动
            frmdata.classProperty += 8;
		return frmdata;
    }

    
    
    //任务类型
    $.getJSON(ctx+'listCSysClass.do',{parentIdSch:78 ,classtypeidSch:3 },function(parentsJson) {
        $("#taskType").combobox({
			data:parentsJson.rows,
			valueField:'text',
	         textField:'text',
	        selected:parentsJson.rows[0],
	        filter: function(q, row){
        		var opts = $(this).combobox('options');
        		return row[opts.textField].indexOf(q) == 0;
        	}
	})
	});
    //交通方式
    $.getJSON(ctx+'listCSysClass.do',{parentIdSch:86 ,classtypeidSch:3 },function(parentsJson) {
        $("#transportation").combobox({
			data:parentsJson.rows,
			valueField:'text',
	         textField:'text',
	        selected:parentsJson.rows[0],
	        filter: function(q, row){
        		var opts = $(this).combobox('options');
        		return row[opts.textField].indexOf(q) == 0;
        	}
	})
	});
  	//职务
    $.getJSON(ctx+'listCSysClass.do',{parentIdSch:83 ,classtypeidSch:3 },function(parentsJson) {
        $("#position").combobox({
			data:parentsJson.rows,
			valueField:'text',
	         textField:'text',
	        selected:parentsJson.rows[0],
	        filter: function(q, row){
        		var opts = $(this).combobox('options');
        		return row[opts.textField].indexOf(q) == 0;
        	}
	})
	});
   //工程师&&人员列表
    $.getJSON(ctx+'listAllSUser.do',{},function(parentsJson) {
        $("#executorId").combobox({
			data:parentsJson.rows,
			valueField:'id',
	         textField:'trueName',
	        selected:parentsJson.rows[0].trueName,
	        filter: function(q, row){
        		var opts = $(this).combobox('options');
        		return row[opts.textField].indexOf(q) == 0;
        	}
	})  

	
	   
	keys = {"id":"姓名1","trueName":"姓名","qq":"QQ","weixin":"微信","roleProperty":"roleProperty"};
	  //addTables(parentsJson,"simpledatatable",keys);
    
	});
   
    $.getJSON(ctx+'listAllSUser.do',{idSch:userId },function(parentsJson) {
    	$("#loginName").html(parentsJson.rows[0].trueName);
    	$(".header-information").html("客服编号：0"+parentsJson.rows[0].id);
    	$(".header-fullname").html(parentsJson.rows[0].trueName);
    	$("#createPerson").val(parentsJson.rows[0].trueName);
	});

   	//客户名称
     $.getJSON(ctx+'listAllSProject.do',{},function(parentsJson) {
    	 $("#taskName").combobox({
 			data:parentsJson.rows,
 			valueField:'shortName',
 	        textField:'shortName',
 	        selected:parentsJson.rows[0],
 	        filter: function(q, row){
         		var opts = $(this).combobox('options');
         		return row[opts.textField].indexOf(q) == 0;
         	},
         	onSelect:function(record){
         		//客户名称
         	    $.getJSON(ctx+'listAllSCustomer.do?idSch='+record.customerId,{},function(parentsJson) {
         	    	$("#customerId").combobox("setValue",parentsJson.rows[0].id==null?"":parentsJson.rows[0].id);
         	    	$("#province").combobox("setValue",parentsJson.rows[0].province==null?"":parentsJson.rows[0].province);
 	                $("#country").combobox("setValue",parentsJson.rows[0].county==null?"":parentsJson.rows[0].county);
 	                $("#level").textbox("setValue",parentsJson.rows[0].level==null?"":parentsJson.rows[0].level);
         		
 	               //客户名称
                    $.getJSON(ctx+'listAllSContact.do',{customerIdSch:record.customerId},function(parentsJson) {
                        $("#contactName").combobox({
                			data:parentsJson.rows,
                			valueField:'name',
                	        textField:'name',
                	        selected:parentsJson.rows[0],
                	        filter: function(q, row){
                        		var opts = $(this).combobox('options');
                        		return row[opts.textField].indexOf(q) == 0;
                        	},
                        	onSelect:function(record){
                        		
                        		$("#position").combobox("setValue",record.position==null?"":record.position);
                                $("#contactPhone").textbox("setValue",record.phone==null?"":record.phone);
                                $("#fixedPhone").textbox("setValue",record.phone==null?"":record.phone);
                        	}
                	})
                	});
         	    
         	    
         	    });
         	}
 		})
     });
   	
   	
    //客户名称
     $.getJSON(ctx+'listAllSContact.do',{},function(parentsJson) {
         $("#contactName").combobox({
 			data:parentsJson.rows,
 			valueField:'name',
 	        textField:'name',
 	        selected:parentsJson.rows[0],
 	        filter: function(q, row){
         		var opts = $(this).combobox('options');
         		return row[opts.textField].indexOf(q) == 0;
         	},
         	onSelect:function(record){
         		
         		 $("#position").combobox("setValue",record.position==null?"":record.position);
                 $("#contactPhone").textbox("setValue",record.phone==null?"":record.phone);
                 $("#fixedPhone").textbox("setValue",record.phone==null?"":record.phone);
         	}
 	})
 	}); 
   	
    //客户名称
    $.getJSON(ctx+'listAllSCustomer.do',{},function(parentsJson) {
        $("#customerId").combobox({
			data:parentsJson.rows,
			valueField:'id',
	        textField:'fullName',
	        selected:parentsJson.rows[0],
	        filter: function(q, row){
        		var opts = $(this).combobox('options');
        		return row[opts.textField].indexOf(q) == 0;
        	},
        	onSelect:function(record){
        		
        		$("#province").combobox("setValue",record.province==null?"":record.province);
                $("#country").combobox("setValue",record.county==null?"":record.county);
                $("#level").textbox("setValue",record.level==null?"":record.level);
                
              //客户名称
                $.getJSON(ctx+'listAllSContact.do',{customerIdSch:record.id},function(parentsJson) {
                    $("#contactName").combobox({
            			data:parentsJson.rows,
            			valueField:'contactName',
            	        textField:'name',
            	        selected:parentsJson.rows[0],
            	        filter: function(q, row){
                    		var opts = $(this).combobox('options');
                    		return row[opts.textField].indexOf(q) == 0;
                    	},
                    	onSelect:function(record){
                    		
                    		$("#position").combobox("setValue",record.position==null?"":record.position);
                            $("#contactPhone").textbox("setValue",record.phone==null?"":record.phone);
                            $("#fixedPhone").textbox("setValue",record.phone==null?"":record.phone);
                    	}
            	})
            	});
                
                
        	}
	})
	});
    
    //  获取县市信息
    $.getJSON(ctx+'listAllAreaDistrict.do',{ },function(parentsJson) {
        $("#country").combobox({
			data:parentsJson.rows,
			valueField:'districtName',
	         textField:'districtName',
	        selected:parentsJson.rows[0],
	        filter: function(q, row){
        		var opts = $(this).combobox('options');
        		return row[opts.textField].indexOf(q) == 0;
        	}
	})
	});
    //获取省市信息
    $.getJSON(ctx+'listAllAreaProvince.do',{ },function(parentsJson) {
        $("#province").combobox({
			data:parentsJson.rows,
			valueField:'provinceName',
	         textField:'provinceName',
	        selected:parentsJson.rows[0],
	        filter: function(q, row){
        		var opts = $(this).combobox('options');
        		return row[opts.textField].indexOf(q) == 0;
        	}
	})
	});
//************combobox******************************
    //数据提取和数据回填  
/*     var actionIds = [];
    function pages(id,data,nums)
    {
         var pages = Math.ceil(data.length/nums); //得到总页数
         var thisDate = function(curr){
         var str = '', last = curr*nums - 1;
         last = last >= data.length ? (data.length-1) : last;
         for(var i = (curr*nums - nums); i <= last; i++){
        	 switch (data[i].status)
        	 {
        	   case '已审核' :  
  				str += '<li id="'+data[i].id+'" class="task-item"><div  class="task-check"></div><div class="task-state"><span class="label label-blue">'+data[i].status+'</span></div><div class="task-time">'+data[i].sendTime.substring(0,10)+' </div><div class="task-body">'+data[i].taskType+'</div><div class="task-creator"><a href=""> </a></div><div class="task-assignedto"> </div></li>';
                actionIds.push(data[i].id);
  				break;
          	   case '已发布' : 
                  str += '<li id="'+data[i].id+'" class="task-item"><div class="task-check"></div><div class="task-state"><span class="label label-orange">已发布</span></div><div class="task-time">'+data[i].sendTime.substring(0,10)+'</div><div class="task-body">'+data[i].taskType+'</div><div class="task-creator"><a href=""> </a></div><div class="task-assignedto"> </div></li>';
                  actionIds.push(data[i].id);
                  break;
          	   case '已完成' :   
                     str += '<li id="'+data[i].id+'" class="task-item"><div class="task-check"></div><div class="task-state"><span class="label label-yellow">已完成</span></div><div class="task-time">'+data[i].sendTime.substring(0,10)+'</div><div class="task-body">'+data[i].taskType+'</div><div class="task-creator"><a href=""> </a></div><div class="task-assignedto"> </div></li>';
                     actionIds.push(data[i].id);
                     break;
          	   case '已归档' :   
                     str += '<li id="'+data[i].id+'" class="task-item"><div class="task-check"></div><div class="task-state"><span class="label label-yellow">已归档</span></div><div class="task-time">'+data[i].sendTime.substring(0,10)+' </div><div class="task-body">'+data[i].taskType+'</div><div class="task-creator"><a href=""> </a></div><div class="task-assignedto"> </div></li>';
                     actionIds.push(data[i].id);
                     break;
          	   case '已回访' :   
                     str += '<li id="'+data[i].id+'" class="task-item"><div class="task-check"></div><div class="task-state"><span class="label label-yellow">已回访</span></div><div class="task-time">'+data[i].sendTime.substring(0,10)+' </div><div class="task-body">'+data[i].taskType+'</div><div class="task-creator"><a href=""> </a></div><div class="task-assignedto"> </div></li>';
                     actionIds.push(data[i].id);
                     break;
          	   case '待发布' :   
                     str += '<li id="'+data[i].id+'" class="task-item aaaaa"><div class="task-check"></div><div class="task-state"><span class="label label-yellow">待发布</span></div><div class="task-time">'+data[i].sendTime.substring(0,10)+' </div><div class="task-body">'+data[i].taskType+'</div><div class="task-creator"><a href=""> </a></div><div class="task-assignedto"> </div></li>';
                     actionIds.push(+data[i].id);
                     break;
          	  case '执行中' :   
                 str += '<li id="'+data[i].id+'" class="task-item aaaaa"><div class="task-check"></div><div class="task-state"><span class="label label-blue">执行中</span></div><div class="task-time">'+data[i].sendTime.substring(0,10)+' </div><div class="task-body">'+data[i].taskType+'</div><div class="task-creator"><a href=""> </a></div><div class="task-assignedto"> </div></li>';
                 actionIds.push(+data[i].id);
                 break;
          	   default : 
          	   break;
        	 }
        	 
         }
         return str;
     }

         //调用分页
        laypage({
            cont: 'task',
            pages: pages,
            jump: function(obj){
                document.getElementById(id).innerHTML = thisDate(obj.curr);
            	for(var key=0; key <actionIds.length;key++ )
                {
	                (function(){
	                    	 var num = actionIds[key];
	                    	 $("#"+actionIds[key]).click(function(){
	    							addAction(num);
	                    		 
	                    	 });
	                })()
                }
                   
            },
            first: false,
            last: false,
            skin: 'molv',
             prev: '<',  
             next: '>'  
        })
      
     
       
    } */
    
   
    function addDomToListById(data,id)
    {
    	var actionIds = [];
    	$("#task_list li").remove();
    	var  str = "";
    	for ( var i = 0 ; i<data.length ; i++)
    	{
	       	 switch (data[i].status)
	    	 {
	    	   case '已审核' :  
					str += '<li id="'+data[i].id+'" class="task-item"><div  class="task-check"></div><div class="task-state"><span class="label label-blue">'+data[i].status+'</span></div><div class="task-time">'+data[i].sendTime.substring(0,10)+' </div><div class="task-body">'+data[i].taskType+'</div><div class="task-creator"><a href=""> </a></div><div class="task-assignedto"> </div></li>';
	            actionIds.push(data[i].id);
					break;
	      	   case '已发布' : 
	              str += '<li id="'+data[i].id+'" class="task-item"><div class="task-check"></div><div class="task-state"><span class="label label-orange">已发布</span></div><div class="task-time">'+data[i].sendTime.substring(0,10)+'</div><div class="task-body">'+data[i].taskType+'</div><div class="task-creator"><a href=""> </a></div><div class="task-assignedto"> </div></li>';
	              actionIds.push(data[i].id);
	              break;
	      	   case '已完成' :   
	                 str += '<li id="'+data[i].id+'" class="task-item"><div class="task-check"></div><div class="task-state"><span class="label label-yellow">已完成</span></div><div class="task-time">'+data[i].sendTime.substring(0,10)+'</div><div class="task-body">'+data[i].taskType+'</div><div class="task-creator"><a href=""> </a></div><div class="task-assignedto"> </div></li>';
	                 actionIds.push(data[i].id);
	                 break;
	      	   case '已归档' :   
	                 str += '<li id="'+data[i].id+'" class="task-item"><div class="task-check"></div><div class="task-state"><span class="label label-yellow">已归档</span></div><div class="task-time">'+data[i].sendTime.substring(0,10)+' </div><div class="task-body">'+data[i].taskType+'</div><div class="task-creator"><a href=""> </a></div><div class="task-assignedto"> </div></li>';
	                 actionIds.push(data[i].id);
	                 break;
	      	   case '已回访' :   
	                 str += '<li id="'+data[i].id+'" class="task-item"><div class="task-check"></div><div class="task-state"><span class="label label-yellow">已回访</span></div><div class="task-time">'+data[i].sendTime.substring(0,10)+' </div><div class="task-body">'+data[i].taskType+'</div><div class="task-creator"><a href=""> </a></div><div class="task-assignedto"> </div></li>';
	                 actionIds.push(data[i].id);
	                 break;
	      	   case '待发布' :   
	                 str += '<li id="'+data[i].id+'" class="task-item aaaaa"><div class="task-check"></div><div class="task-state"><span class="label label-yellow">待发布</span></div><div class="task-time">'+data[i].sendTime.substring(0,10)+' </div><div class="task-body">'+data[i].taskType+'</div><div class="task-creator"><a href=""> </a></div><div class="task-assignedto"> </div></li>';
	                 actionIds.push(data[i].id);
	                 break;
	      	  case '执行中' :   
	             str += '<li id="'+data[i].id+'" class="task-item aaaaa"><div class="task-check"></div><div class="task-state"><span class="label label-blue">执行中</span></div><div class="task-time">'+data[i].sendTime.substring(0,10)+' </div><div class="task-body">'+data[i].taskType+'</div><div class="task-creator"><a href=""> </a></div><div class="task-assignedto"> </div></li>';
	             actionIds.push(data[i].id);
	             break;
	      	   default : 
	      	   break;
	    	 }
    	}
    	 document.getElementById(id).innerHTML = str;
    	 //添加动作响应
    	
	   	 for(var key=0; key <actionIds.length;key++ )
	        {
	            (function(){
	                	 var num = actionIds[key];
	                	 $("#"+actionIds[key]).click(function(){
								addAction(num);
	                		 
	                	 });
	            })()
	        }
    }
 function loadlist(url,id,pageId,pageSize){
	 pageSize = 6;
	 $.getJSON(ctx+url,{pageSize:pageSize},function(parentsJson) {
	    	
	      	addDomToListById(parentsJson.rows,id);
	      	$.jqPaginator('#'+pageId, {
	            totalPages: parentsJson.pageCount,
	            visiblePages: pageSize,
	            currentPage: 1,
	            onPageChange: function (num, type) {
	            	  $.getJSON(ctx+url,{pageSize:pageSize,pageIndex:num},function(parentsJson) {
	            		  addDomToListById(parentsJson.rows,id);
	            		 
	            	  }); 
	            }
	        });
	      	
	  	});
 }   
 
   
    
	
    
    //表格初始化方法
    function listActionByUser(pageIndex, pageSize, needPage,url,id,paginationId,headNames) {
        var json = {
            pageIndex: pageIndex,
            pageSize: pageSize
        };
        callSapiServer(url, function (data) {
            var head = headNames;
            tab_jsonTable($(id), data.rows, head,
                    function (td, row, col, content) {
                        $(td).css("text-align", "center");
                        switch (col) {
                            case 0:
                                return nullToString(content.trueName);
                            default :
                                return null;
                        }
                    }, function (table) {
                        $(table).addClass("table table-striped table-hover table-bordered");
                     
                    }
            );

            if (needPage) 
            {//分页
         	   
                if (data.total && data.total >= 0) {
             	 
                    common_pagination($(paginationId), data.total, data.pageSize, data.pageIndex, 16, function (pi, totalCount, count, ul) {
                    	 if (needPage) {
                            $(ul).find("a").each(function () {
                                $(this).attr("href", "javaScript:void(0);");
                            });
                        }
                        listActionByUser(pi, data.pageSize, needPage,url,id,paginationId,headNames);
                    });
                }
 		       else
 		       $(paginationId).empty();
            }
        }, "POST", json);
    }
    
    
    //报销列表审核表格初始化方法
    
    function ReimburseCheck(pageIndex, pageSize, needPage,url,id,paginationId,headNames) {
        var json = {
            pageIndex: pageIndex,
            pageSize: pageSize
        };
        callSapiServer(url, function (data) {
            var head = headNames;
            tab_jsonTable($(id), data.rows, head,
                    function (td, row, col, content) {
                        $(td).css("text-align", "center");
                        switch (col) {
                            case 0:
                                return nullToString(content.abstractInfo);
                            case 1:
                                return nullToString(content.amount);
                            case 2: 
                            	return '<a class="ReimburseCheck"  data-toggle="modal" data-target=".bs-example-modal-ReimburseCheck" id="'+content.id+'">' + nullToString(content.excutor.trueName) +'</a>';
                            default :
                                return null;
                        }
                    }, function (table) {
                        $(table).addClass("table table-striped table-hover table-bordered");
                        
                         $(".ReimburseCheck").click(function (){
                        	ReimburseCheckDetail(1, 5, false,url,"#ReimburseCheckDetail","#ReceiptPage",["费用名称","金额","姓名","审核"]) ;

                        }); 
                        
                      /*  $(table).find("a[name='set_action_btn']").click(function(){
                            var id = $(this).parents("tr").find("input[name='id']").val();
                            var user_id = $("#user_id").val();
                            var json = {
                                userId : user_id,
                                actionId : id
                            };
                            callSapiServer("/action/setUserAction",function(data){
                                alert(data.message);
                                listActionByUser(1,15,true);
                            },"POST",json);
                         });*/
                    }
            );

            if (needPage) 
            {//分页
         	   
                if (data.total && data.total >= 0) {
             	 
                    common_pagination($(paginationId), data.total, data.pageSize, data.pageIndex, 3, function (pi, totalCount, count, ul) {
                    	 if (needPage) {
                            $(ul).find("a").each(function () {
                                $(this).attr("href", "javaScript:void(0);");
                            });
                        }
                    	ReimburseCheck(pi, data.pageSize, needPage,url,id,paginationId,headNames);
                    });
                }
 		       else
 		       $(paginationId).empty();
            }
        }, "POST", json);
    }
    
  
   
   //报销列表审核表格初始化方法
   
   function carRecordDetail(pageIndex, pageSize, needPage,url,id,paginationId,headNames) {
       var json = {
           pageIndex: pageIndex,
           pageSize: pageSize
       };
       callSapiServer(url, function (data) {
           var head = headNames;
           tab_jsonTable($(id), data.rows, head,
                   function (td, row, col, content) {
                       $(td).css("text-align", "center");
                       switch (col) {
                           case 0:
                               return nullToString(content.carNumber);
                           case 1:
                               return nullToString(content.type);
                           case 2: 
                        	   return nullToString(content.departTime);
                           case 3:
                               return nullToString(content.arriveTime);
                           case 4:
                               return nullToString(content.beginKilometre);
                           case 5: 
                        	   return nullToString(content.endKilometre);
                           case 6: 
                        	   return nullToString(content.kilometre);
                           case 7: 
                        	   return nullToString(content.remark);
                           case 8:
                        	   
       	           	    	if(content.status == "0" )
       	           	    	{
       	           	    		return  '<button class="checkCarRecord" value="'+ content.id + '" id="carRecordDetail'+ content.id+ '"> 待审核 </button>';
       	           	    	}
                           	else
                           	{
                           		return  '<button class="button" id="carRecordDetail'+ content.id+ '"  > 已审核 </button>';
                           	}
                           default :
                               return null;
                       }
                   }, function (table) {
                       $(table).addClass("table table-striped table-hover table-bordered");
                 	   $(".checkCarRecord").click(function(){
                 			$.getJSON(ctx+'updateSReimburse.do',{status: 1 , id : this.value},function(parentsJson) {
                   		   }); 
                 		   console.log(this.id);
                  		   $("#"+this.id).html("已审核");
                 	   });
                       
                     /*  $(table).find("a[name='set_action_btn']").click(function(){
                           var id = $(this).parents("tr").find("input[name='id']").val();
                           var user_id = $("#user_id").val();
                           var json = {
                               userId : user_id,
                               actionId : id
                           };
                           callSapiServer("/action/setUserAction",function(data){
                               alert(data.message);
                               listActionByUser(1,15,true);
                           },"POST",json);
                        });*/
                   }
           );

           if (needPage) 
           {//分页
        	   
               if (data.total && data.total >= 0) {
            	 
                   common_pagination($(paginationId), data.total, data.pageSize, data.pageIndex, 3, function (pi, totalCount, count, ul) {
                   	 if (needPage) {
                           $(ul).find("a").each(function () {
                               $(this).attr("href", "javaScript:void(0);");
                           });
                       }
                   	ReimburseCheck(pi, data.pageSize, needPage,url,id,paginationId,headNames);
                   });
               }
		       else
		       $(paginationId).empty();
           }
       }, "POST", json);
   }
    
 	$(".ReimburseCheck").click(function (){
    	
    	alert("hahha");
    	
    });
    //行车记录审核
    
    function carRecord(pageIndex, pageSize, needPage,url,id,paginationId,headNames) {
        var json = {
            pageIndex: pageIndex,
            pageSize: pageSize
        };
        callSapiServer(url, function (data) {
            var head = headNames;
            tab_jsonTable($(id), data.rows, head,
                    function (td, row, col, content) {
                        $(td).css("text-align", "center");
                        switch (col) {
                            case 0:
                                return nullToString(content.name);
                            case 1:
                                return nullToString(content.amount);
                            case 2:
                            	return '<a class="carRecord" data-toggle="modal" data-target=".bs-example-modal-carRecord" id="'+content.id+'">' + nullToString(content.excutor.trueName) +'</a>';
                            default :
                                return null;
                        }
                    }, function (table) {
                        $(table).addClass("table table-striped table-hover table-bordered");
                        $(".carRecord").click(function (){
                        	carRecordDetail(1, 5, false,url,"#carRecordDetail","#ReceiptPage",["车牌号","类型","行车时间－开始","行车时间－结束","里程表－开始","里程表－结束","公里数","备注","审核"]) ;
                    	});
                    }
            );

            if (needPage) 
            {//分页
         	   
                if (data.total && data.total >= 0) {
             	 
                    common_pagination($(paginationId), data.total, data.pageSize, data.pageIndex, 2, function (pi, totalCount, count, ul) {
                    	 if (needPage) {
                            $(ul).find("a").each(function () {
                                $(this).attr("href", "javaScript:void(0);");
                            });
                        }
                    	 carRecord(pi, data.pageSize, needPage,url,id,paginationId,headNames);
                    });
                }
 		       else
 		       $(paginationId).empty();
            }
        }, "POST", json);
    }
    
    function ReimburseCheckDetail(pageIndex, pageSize, needPage,url,id,paginationId,headNames) {
        var json = {
            pageIndex: pageIndex,
            pageSize: pageSize
        };
        callSapiServer(url, function (data) {
            var head = headNames;
            tab_jsonTable($(id), data.rows, head,
                    function (td, row, col, content) {
                        $(td).css("text-align", "center");
                        switch (col) {
                            case 0:
                                return nullToString(content.abstractInfo);
                            case 1:
                                return nullToString(content.amount);
                            case 2:
                            	return '<a class="carRecord" data-toggle="modal" data-target=".bs-example-modal-carRecord" id="bx">' + nullToString(content.excutor.trueName) +'</a>';
                            case 3:
           	           	    	if(content.status == "0" )
           	           	    	{
           	           	    		return '<button class="ReimburseCheckDetail" value="'+ content.id + '" id="ReimburseCheckDetail'+ content.id+ '"> 待审核 </button>';
           	           	    	}
                               	else
                               	{
                               		return  '<button class="button" id="ReimburseCheckDetail'+ content.id+ '"  > 已审核 </button>';
                               	}
                            default :
                                return null;
                        }
                    }, function (table) {
                        $(table).addClass("table table-striped table-hover table-bordered");
                        $(".ReimburseCheckDetail").click(function(){
                 			$.getJSON(ctx+'updateSReceipt.do',{status: 1 , id : this.value},function(parentsJson) {
                   		   }); 
                  		   $("#"+this.id).html("已审核");
                 	   });
                    }
            );

            if (needPage) 
            {//分页
         	   
                if (data.total && data.total >= 0) {
             	 
                    common_pagination($(paginationId), data.total, data.pageSize, data.pageIndex, 2, function (pi, totalCount, count, ul) {
                    	 if (needPage) {
                            $(ul).find("a").each(function () {
                                $(this).attr("href", "javaScript:void(0);");
                            });
                        }
                    	 carRecord(pi, data.pageSize, needPage,url,id,paginationId,headNames);
                    });
                }
 		       else
 		       $(paginationId).empty();
            }
        }, "POST", json);
    } 
//报销列表审核表格初始化方法
 
 function workRecord(pageIndex, pageSize, needPage,url,id,paginationId,headNames) {
     var json = {
         pageIndex: pageIndex,
         pageSize: pageSize
     };
     callSapiServer(url, function (data) {
         var head = headNames;
         tab_jsonTable($(id), data.rows, head,
                 function (td, row, col, content) {
                     $(td).css("text-align", "center");
                     switch (col) {
                         case 0:
                             return nullToString(content.workRecord);
                         default :
                             return null;
                     }
                 }, function (table) {
                     $(table).addClass("table table-striped table-hover table-bordered");
                 }
         );

         if (needPage) 
         {//分页
      	   
             if (data.total && data.total >= 0) {
          	 
                 common_pagination($(paginationId), data.total, data.pageSize, data.pageIndex, 3, function (pi, totalCount, count, ul) {
                 	 if (needPage) {
                         $(ul).find("a").each(function () {
                             $(this).attr("href", "javaScript:void(0);");
                         });
                     }
                 	ReimburseCheck(pi, data.pageSize, needPage,url,id,paginationId,headNames);
                 });
             }
       else
       $(paginationId).empty();
         }
     }, "POST", json);
 }
    
</script>
